<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="h" uri="/syzg-html"%>
<%
	request.setAttribute("ctx", request.getContextPath());
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
	request.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html>
<body>
<div class="modal fade bs-example-modal-md" id="viewNewsdetailModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog modal-md" role="document" style="margin-top: 0">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" onclick="javascript:$('#viewNewsdetailModal').modal('hide');" aria-label="Close">&times;</button>
        <h4 class="modal-title" id="myModalLabel">修改图片描述信息</h4>
      </div>
      <div class="modal-body" id="modalCore">
	    <div class="modal-body-wrap" style="width:100%;height:360px;background-size:100% 100%;background-image: url(${ctx}${newsdetailinfo.path });">
	      <form class="form-horizontal mod-editGrid-form" role="form" id="viewNewsDetailForm" name="viewNewsDetailForm">
          <fieldset>
          <input type="hidden" name="id" value="${newsdetailinfo.id}"/>
            <!-- generate code start -->

            <div class="form-group">
              <label class="col-sm-2 control-label" for="remark"><i class="fa fa-file-text-o"></i>图片描述</label>
              <div class="col-sm-10">
                <label id="l_remark">${newsdetailinfo.remark}</label>
                <input type="text" id="remark" name="remark" value="${newsdetailinfo.remark}" class="form-control" style="display: none;"/>
              </div>
            </div>
            
            <div class="form-group">
              <label class="col-sm-2 control-label" for="artist"><i class="fa fa-camera-retro"></i>摄影师</label>
              <div class="col-sm-10">
                <label id="l_artist">${newsdetailinfo.artist}</label>
                <input type="text" id="artist" name="artist" value="${newsdetailinfo.artist}" class="form-control" style="display: none;" />
              </div>
            </div>
            
            <div class="form-group">
              <label class="col-sm-2 control-label" for="shootingTime"><i class="fa fa-clock-o"></i>拍摄时间</label>
              <div class="col-sm-10">
                <label id="l_shootingTime"><fmt:formatDate pattern="yyyy-MM-dd HH:mm" value="${newsdetailinfo.shootingTime}"/></label>
                <input type="text" id="shootingTime" name="shootingTime" readonly="readonly" value="<fmt:formatDate pattern="yyyy-MM-dd HH:mm" value="${newsdetailinfo.shootingTime}"/>" class="form-control" style="display: none;" />
			    <script type="text/javascript">
               	  $('#shootingTime').datetimepicker({
               	      format: 'yyyy-mm-dd hh:ii',
               	  	  todayBtn:  'linked',
               	  	  language:  'zh-CN',
               	  	  startView: 2,
               	  	  minView: 1,
               	  	  pickerPosition:'top-right',
               	  	  autoclose: 1
               	  });
			    </script>
              </div>
            </div>

			<!-- generate code end -->
          </fieldset>
        </form>
	    </div>
      </div>
      <div class="modal-footer">
        <button id="btn_close" type="button" class="btn btn-default" onclick="javascript:$('#viewNewsdetailModal').modal('hide');">关闭</button>
        <button id="btn_edit" type="button" class="btn btn-primary" onclick="showInput();">修改</button>
        <button id="btn_back" type="button" class="btn btn-default" onclick="showLabel();" style="display: none;">返回</button>
        <button id="btn_save" type="button" class="btn btn-primary" onclick="saveNewsDetailinfo();" style="display: none;">保存</button>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
function showInput(){
	$("#remark").show();
	$("#remark").val($("#l_remark").html());
	$("#l_remark").hide();
	$("#artist").show();
	$("#artist").val($("#l_artist").html());
	$("#l_artist").hide();
	$("#shootingTime").show();
	$("#shootingTime").val($("#l_shootingTime").html());
	$("#l_shootingTime").hide();
	$("#btn_close").hide();
	$("#btn_edit").hide();
	$("#btn_back").show();
	$("#btn_save").show();
}

function showLabel(){
	$("#remark").hide();
	$("#l_remark").show();
	$("#artist").hide();
	$("#l_artist").show();
	$("#shootingTime").hide();
	$("#l_shootingTime").show();
	$("#btn_close").show();
	$("#btn_edit").show();
	$("#btn_back").hide();
	$("#btn_save").hide();
}

function saveNewsDetailinfo(){
	var shootingTime = $('#shootingTime').val();
	if(shootingTime == '')
	{
	alert("请选填拍摄时间");
	}
	$.post("${ctx}/path/newsinfo/saveNewsdetail",$("#viewNewsDetailForm").serialize(),function(data){
		var result = eval('(' + data + ')');
		if(result.success==true){
		    alert("修改成功");
			showLabel();
			$("#l_remark").html(result.obj.remark);
			$("#l_artist").html(result.obj.artist);
			$("#l_shootingTime").html($("#shootingTime").val());
		} else {
			bootbox.alert("<h4>操作失败,原因：" + result.webInfo.errorList + "</h4>", function(){});
		}
	});
}
</script>
</body>
</html>